Management of thrashing in a GPU

ABSTRACT

Systems, apparatuses, and methods for managing a number of wavefronts permitted to concurrently execute in a processing system. An apparatus includes a register file with a plurality of registers and a plurality of compute units configured to execute wavefronts. A control unit of the apparatus is configured to allow a first number of wavefronts to execute concurrently on the plurality of compute units. The control unit is configured to allow no more than a second number of wavefronts to execute concurrently on the plurality of compute units, wherein the second number is less than the first number, in response to detection that thrashing of the register file is above a threshold. The control unit is configured to detect said thrashing based at least in part on a number of registers in use by executing wavefronts that spill to memory.

BACKGROUND Description of the Related Art

A graphics processing unit (GPU) is a complex integrated circuit thatperforms graphics-processing tasks. For example, a GPU executesgraphics-processing tasks required by an end-user application, such as avideo-game application. GPUs are also increasingly being used to performother tasks which are unrelated to graphics. The GPU can be a discretedevice or can be included in the same device as another processor, suchas a central processing unit (CPU).

In many applications executed by a GPU, a sequence of work-items, whichcan also be referred to as threads, are processed so as to output afinal result. In one implementation, each processing element executes arespective instantiation of a particular work-item to process incomingdata. A work-item is one of a collection of parallel executions of akernel invoked on a compute unit. A work-item is distinguished fromother executions within the collection by a global ID and a local ID. Asubset of work-items in a workgroup that execute simultaneously togetheron a compute unit can be referred to as a wavefront, warp, or vector.The width of a wavefront is a characteristic of the hardware of thecompute unit. As used herein, the term “compute unit” is defined as acollection of processing elements (e.g., single-instruction,multiple-data (SIMD) units) that perform synchronous execution of aplurality of work-items. The number of processing elements per computeunit can vary from implementation to implementation. A “compute unit”can also include a local data store and any number of other executionunits such as a vector memory unit, a scalar unit, a branch unit, and soon. Also, as used herein, a collection of cooperating wavefronts arereferred to as a “workgroup”.

A typical application executing on a GPU relies on function inlining andstatic reservation of registers to a workgroup. Currently, GPUs exposeregisters to the machine instruction set architecture (ISA) using flatarray semantics and statically reserve a specified number of physicalregisters before the wavefronts of a workgroup begin executing. Thisstatic array-based approach underutilizes physical registers andeffectively requires in-line compilation, making it difficult to supportmany modern programming features. In some cases, the register demands ofthe wavefronts leave the compute units underutilized. Alternatively,applications which limit register use must often spill to memory leadingto performance degradation and extra contention for memory bandwidth.

BRIEF DESCRIPTION OF THE DRAWINGS

The advantages of the methods and mechanisms described herein may bebetter understood by referring to the following description inconjunction with the accompanying drawings, in which:

FIG. 1 is a block diagram of one implementation of a computing system.

FIG. 2 is a block diagram of another implementation of a computingsystem.

FIG. 3 is a block diagram of one implementation of a compute unit.

FIG. 4 is a block diagram of one implementation of a compute unit.

FIG. 5 is a generalized flow diagram illustrating one implementation ofa method for dynamic register allocation.

FIG. 6 is a generalized flow diagram illustrating one implementation ofa method for determining when to throttle the launching of newworkgroups.

FIG. 7 is a generalized flow diagram illustrating one implementation ofa method for adjusting the number of workgroups permitted to beassigned.

FIG. 8 is a generalized flow diagram illustrating one implementation ofa method for switching between spilling modes.

FIG. 9 is a generalized flow diagram illustrating one implementation ofa method for determining workgroups that are allowed to cause spilling.

FIG. 10 is a generalized flow diagram illustrating one implementation ofa method for cooperative wavefront scheduling.

FIG. 11 is a generalized flow diagram illustrating one implementation ofa method for wavefront descheduling and rescheduling.

FIG. 12 is a generalized flow diagram illustrating one implementation ofa method for dynamically adjusting register allocation on functionboundaries.

FIG. 13 is a generalized flow diagram illustrating one implementation ofa method for dynamically allocating registers to ensure forwardprogress.

FIG. 14 is a generalized flow diagram illustrating one implementation ofa method for dynamically adjusting wavefronts executing per epoch basedon an amount of register threshing.

DETAILED DESCRIPTION OF IMPLEMENTATIONS

In the following description, numerous specific details are set forth toprovide a thorough understanding of the methods and mechanisms presentedherein. However, one having ordinary skill in the art should recognizethat the various implementations may be practiced without these specificdetails. In some instances, well-known structures, components, signals,computer program instructions, and techniques have not been shown indetail to avoid obscuring the approaches described herein. It will beappreciated that for simplicity and clarity of illustration, elementsshown in the figures have not necessarily been drawn to scale. Forexample, the dimensions of some of the elements may be exaggeratedrelative to other elements.

Systems, apparatuses, and methods for dynamic register allocation aredisclosed. In one implementation, a system includes at least a hostprocessing unit (e.g., central processing unit (CPU)) and a parallelprocessing unit (e.g., graphics processing unit (GPU)) for executing aplurality of wavefronts in parallel. In one implementation, the parallelprocessing unit includes a command processor, a dispatch unit, a controlunit, and a plurality of compute units. The command processor receiveskernels from the host processing unit and communicates with the dispatchunit to dispatch corresponding wavefronts to the compute units.

In one implementation, if a new wavefront requests more registers thanare currently available on the CU, the control unit spills registersassociated with stack frames at the bottom of a stack since they willnot be used in the near future and should be the first entries spilledto memory. The control unit determines how many registers to spill basedon dynamic demands and prefetches upcoming necessary fills withoutsoftware involvement. Effectively, the control unit manages the physicalregister file as a cache in this implementation.

In one implementation, in order to enable dynamic register allocationfor workgroups, registers are referenced using stack semantics. Also,younger workgroups are dynamically descheduled so that older workgroupscan allocate additional registers when needed to ensure improvedfairness and better forward progress guarantees. In one implementation,dynamic register allocation instructions are executed so as to allocatea dynamic frame of registers. Also, synchronization instructions areexecuted to identify when a workgroup is waiting for certaincommunication events and can be descheduled to participate incooperative scheduling.

During runtime, a wavefront might not need as many registers at a givenmoment in time as were statically allocated to the wavefront at launch.Typically, a compiler statically allocates a number of registers thatthe wavefront will use in the worst-case scenario. To mitigate thisscenario, mechanisms and methods are presented herein which allow fordynamically managing the registers available to a wavefront as needed.This reduces the amount of registers that are allocated to a wavefrontat launch, enabling more wavefronts to be executed concurrently on theprocessing unit. For example, in one implementation, when a wavefrontmakes a function call, additional registers can be assigned to thewavefront if the given function uses a relatively large number ofregisters. When the given function completes execution, the additionalregisters are deallocated and potentially assigned to other wavefronts.It is noted that the proposed mechanisms are not solely tied to orexecuted as part of a function call and return. For example, in oneimplementation, upon entry, a function may need a certain number ofregisters, then at some point either release some registers or ask formore registers. Also, the final deallocation as the function returnsdoes not need to be built into the return instruction itself.

In one implementation, if an older wavefront needs additional registers,but a younger wavefront is using a relatively large number of registers,the registers can be deallocated from the younger wavefront and providedto the older wavefront so that the older wavefront can make forwardprogress. This can help avoid a deadlock scenario where the GPUdeadlocks if the older wavefront is not able to make forward progressdue to the resources being utilized by younger wavefronts. This alsoallows younger wavefronts to be launched when an older wavefront iswaiting for a synchronization event since the younger wavefronts can bedescheduled as needed to permit the older wavefront to be resumed.

In one implementation, the control unit monitors the dispatch ofwavefronts to the compute units. Also, the control unit dynamicallyassigns registers to newly dispatched wavefronts to better manage theavailable registers. This is in contrast to statically assigning a fixedamount of registers to wavefronts at dispatch. During execution of awavefront, each time a function is called within the wavefront, a set ofregisters are allocated to the function being called. If not enoughregisters are available for the new function, then one or more stackframes are spilled to memory. Preferably, the lowest stack frames on thestack are spilled to memory since the corresponding functions are lesslikely to be accessed in the near future. When the callee functionfinishes execution and execution returns to the caller function, theregisters are returned to the free pool for use by other stack frames.

In one implementation, the control unit manages the dynamic schedulingand descheduling of wavefronts based on resource availability of theprocessing unit (e.g., GPU). In one implementation, the goal of thecontrol unit is to maximize the performance and/or throughput of theprocessing unit performing meaningful work while ensuring forwardprogress is maintained. If the control unit schedules too manywavefronts on the compute units, the wavefronts will be competing forresources and may not make sufficient forward progress. For example, ifwavefronts are spilling registers to memory and then having to restoreregisters from memory, this writing and reading data back and forth frommemory does not translate to making forward progress in the execution ofa workload. Also, in some cases, if a newer wavefront is brought ontothe processing unit to execute while an older wavefront is descheduled,the newer wavefront could eventually be stalled waiting for a resultfrom the older wavefront. This could result in a deadlock where thenewer wavefront stalls and prevents the older wavefront from beingbrought back to execute on the processing unit.

In one implementation, in order to prevent excessive thrashing whilestill ensuring the processing unit's resources are being fully utilized,the control unit tracks the number of wavefront registers that arespilled per epoch. If the number of wavefront registers spilled perepoch exceeds a threshold, then the control unit reduces the number ofwavefronts that are allowed to be scheduled and dispatched in the nextepoch. This allows the control unit to determine the optimal rate atwhich wavefronts should be scheduled to take advantage of the availableresources while avoiding excessive resource contention. Training may beconducted over a series of epochs in which for each epoch the totalityor a subset of the training data set is repeated, often in random orderof presentation, and the process of repeated training epochs iscontinued until the accuracy of the network reaches a satisfactorylevel. As used herein, an “epoch” refers to a period of time (e.g., anumber clock cycles, transactions, etc.).

Referring now to FIG. 1 , a block diagram of one implementation of acomputing system 100 is shown. In one implementation, computing system100 includes at least processors 105A-N, input/output (I/O) interfaces120, bus 125, memory controller(s) 130, network interface 135, memorydevice(s) 140, display controller 150, and display 155. In otherimplementations, computing system 100 includes other components and/orcomputing system 100 is arranged differently. Processors 105A-N arerepresentative of any number of processors which are included in system100.

In one implementation, processor 105A is a general purpose processor,such as a central processing unit (CPU). In this implementation,processor 105A executes a driver 110 (e.g., graphics driver) forcommunicating with and/or controlling the operation of one or more ofthe other processors in system 100. It is noted that depending on theimplementation, driver 110 can be implemented using any suitablecombination of hardware, software, and/or firmware. In oneimplementation, processor 105N is a data parallel processor with ahighly parallel architecture. Data parallel processors include graphicsprocessing units (GPUs), digital signal processors (DSPs), fieldprogrammable gate arrays (FPGAs), application specific integratedcircuits (ASICs), and so forth. In some implementations, processors105A-N include multiple data parallel processors. In one implementation,processor 105N is a GPU which renders pixel data representing an imageto be provided to display controller 150 to be driven to display 155.

In one implementation, system 100 executes a ray tracing workload whichuse dynamic loading of libraries where shaders process a stream ofscenes. In other implementations, system 100 executes other types ofworkloads which rely on the dynamic loading of libraries. While theprior art relies on inline compilation and static reservation ofregisters to a workgroup, the methods and mechanisms described hereinenable dynamic register allocation for workgroups. The prior art exposesregisters to the machine instruction set architecture (ISA) using flatarray semantics and statically reserves a specified number of physicalregisters before the waves of a workgroup begin executing. While simple,this static array-based approach underutilizes physical registers andeffectively requires in-line compilation, making it difficult to supportmany modern programming features unless conservative function callingconventions are introduced. In contrast, the dynamic register allocationtechniques using stack semantics described herein enable improvedutilization and better programming language support.

In one implementation, dynamic register allocation involves sharingregisters between the workgroups executing on the same compute unit. Inanother implementation, dynamic register allocation register involvesallocating a fixed pool of registers to each wavefront and allowingunique frames (i.e., function calls) to dynamically manage that pool.However, the register demand of each frame can leave the physicalregister file underutilized and excessive spilling to memory can lead toperformance degradation. As used herein, the term “spill” is defined asstoring one or more register values of locations in the physicalregister file to memory so as to make those physical register filelocations available for storing values for other variables.

In one implementation, the technique of descheduling lower priority(i.e., younger) workgroups so that they relinquish their registers andallow higher priority workgroups to proceed can lead to deadlock whenyounger work-groups are involved in inter-work-group synchronization(i.e., holding a lock). Furthermore, frequent significant changes in thenumber of registers assigned per workgroup can lead to excessiveworkgroup context swapping and extra contention for memory bandwidth.Prior art techniques use flat array-based register access semanticswhich provide hardware little context on which registers are most likelyto be accessed first. In contrast, the improved techniques describedherein combine cooperative scheduling techniques, dynamically adjustingthe rate at which workgroups are assigned to compute units, and stacksemantics for accessing registers. The combination of these techniquesensures that applications are guaranteed to make forward progress andavoid excessive context swapping.

Memory controller(s) 130 are representative of any number and type ofmemory controllers accessible by processors 105A-N. While memorycontroller(s) 130 are shown as being separate from processor 105A-N, itshould be understood that this merely represents one possibleimplementation. In other implementations, a memory controller 130 can beembedded within one or more of processors 105A-N and/or a memorycontroller 130 can be located on the same semiconductor die as one ormore of processors 105A-N. Memory controller(s) 130 are coupled to anynumber and type of memory devices(s) 140. Memory device(s) 140 arerepresentative of any number and type of memory devices. For example,the type of memory in memory device(s) 140 includes Dynamic RandomAccess Memory (DRAM), Static Random Access Memory (SRAM), GraphicsDouble Data Rate 6 (GDDR6) Synchronous DRAM (SDRAM), NAND Flash memory,NOR flash memory, Ferroelectric Random Access Memory (FeRAM), or others.

I/O interfaces 120 are representative of any number and type of I/Ointerfaces (e.g., peripheral component interconnect (PCI) bus,PCI-Extended (PCI-X), PCIE (PCI Express) bus, gigabit Ethernet (GBE)bus, universal serial bus (USB)). Various types of peripheral devices(not shown) are coupled to I/O interfaces 120. Such peripheral devicesinclude (but are not limited to) displays, keyboards, mice, printers,scanners, joysticks or other types of game controllers, media recordingdevices, external storage devices, network interface cards, and soforth. Network interface 135 is able to receive and send networkmessages across a network.

In various implementations, computing system 100 is a computer, laptop,mobile device, game console, server, streaming device, wearable device,or any of various other types of computing systems or devices. It isnoted that the number of components of computing system 100 varies fromimplementation to implementation. For example, in other implementations,there are more or fewer of each component than the number shown in FIG.1 . It is also noted that in other implementations, computing system 100includes other components not shown in FIG. 1 . Additionally, in otherimplementations, computing system 100 is structured in other ways thanshown in FIG. 1 .

Turning now to FIG. 2 , a block diagram of another implementation of acomputing system 200 is shown. In one implementation, system 200includes GPU 205 and system memory 225. System 200 also includes othercomponents which are not shown to avoid obscuring the figure. GPU 205includes at least command processor(s) 235, control unit 240, dispatchunit 250, compute units 255A-N, memory controller(s) 220, global datashare 270, shared level one (L1) cache 265, and level two (L2) cache(s)260. It should be understood that the components and connections shownfor GPU 205 are merely representative of one type of GPU. This exampledoes not preclude the use of other types of GPUs (or other types ofparallel processors) for implementing the techniques presented herein.In other implementations, GPU 205 includes other components, omits oneor more of the illustrated components, has multiple instances of acomponent even if only one instance is shown in FIG. 2 , and/or isorganized in other suitable manners. Also, each connection shown in FIG.2 is representative of any number of connections between components.Additionally, other connections can exist between components even ifthese connections are not explicitly shown in FIG. 2 .

In various implementations, computing system 200 executes any of varioustypes of software applications. As part of executing a given softwareapplication, a host CPU (not shown) of computing system 200 launcheskernels to be executed by GPU 205. Command processor(s) 235 receivekernels from the host CPU and use dispatch unit 250 to dispatchwavefronts of these kernels to compute units 255A-N. In oneimplementation, control unit 240 includes circuitry for dynamicallyallocating registers 257A-N to dispatched wavefronts at call boundaries.However, in other implementations, register allocation and deallocatecan occur at other points in time which are unrelated to call or returnboundaries. Threads within wavefronts executing on compute units 255A-Nread and write data to corresponding local memory 230A-N, registers257A-N, global data share 270, shared L1 cache 265, and L2 cache(s) 260within GPU 205. It is noted that L1 cache 265 can include separatestructures for data and instruction caches. It is also noted that globaldata share 270, shared L1 cache 265, L2 cache(s) 260, memory controller220, system memory 225, and local memory 230 can collectively bereferred to herein as a “memory subsystem”. It should be understood thatwhen registers 257A-N are described as being spilled to memory, this canrefer to the values being written to any location or level within thememory subsystem.

Referring now to FIG. 3 , a block diagram of one implementation of acompute unit 300 is shown. In one implementation, the components ofcompute unit 300 are included within compute units 255A-N of GPU 205 (ofFIG. 2 ). It should be understood that compute unit 300 can also includeother components (e.g., wavefront scheduler) which are not shown toavoid obscuring the figure. Also, it is noted that the arrangement ofcomponents shown for compute unit 300 are merely indicative of oneparticular implementation. In other implementations, compute unit 300can have other arrangements of components.

In one implementation, dispatch unit 305 receives wavefronts from acommand processor (e.g., command processor 235 of FIG. 2 ) for launchingon single-instruction, multiple-data (SIMD) units 350A-N. SIMD units350A-N are representative of any number of SIMD units, with the numbervarying according to the implementation. In one implementation, dispatchunit 305 maintains reservation station 320 to keep track of in-flightwavefronts. As shown in FIG. 3 , reservation station 320 includesentries for wavefronts 322, 323, 324, and 325, which are representativeof any number of outstanding wavefronts. It should be understood thatthe number of outstanding wavefronts can vary during execution of anapplication. It is noted that reservation station 320 can also bereferred to as ordered list 320 where the wavefronts are orderedaccording to their relative age.

In one implementation, when dispatch unit 305 is getting ready to launcha new wavefront, dispatch unit 305 queries control unit 310 to determinean initial number of registers to allocate to the new wavefront. In thisimplementation, control unit 310 queries register assignment unit 315when determining how to dynamically allocate registers at thegranularity of the functions of wavefronts. In one implementation,register assignment unit 315 includes free register list 317 whichincludes identifiers (IDs) of the registers of vector register file(VRF) 355A-F that are currently available for allocation. If there areenough registers available in free register list 317 for a new functionof a wavefront, then control unit 310 assigns the initial frame to theseregisters. Otherwise, if there are insufficient registers available infree register list 317 for the new function, then control unit 310 willdeallocate (i.e., spill) registers of one or more stack frames ofin-flight wavefront functions. As used herein, the term “stack frame” isdefined as the input parameters, local variables, and output parametersof a given function. A new stack frame is created by a function call,and the stack frame is automatically deallocated on a return from thefunction call. It is noted that it is not necessary to couple registerallocation and deallocation to functional call boundaries.

In order to determine which registers to spill to cache subsystem 360and/or memory subsystem 365, control unit 310 queries stack frame tables330A-N. In one implementation, a separate stack frame table 330A-N ismaintained for each separate wavefront executing on compute unit 300. Inanother implementation, a separate stack frame table 330A-N ismaintained for each VRF 355A-N of a corresponding SIMD 350A-N. Eachstack frame table 330A-N identifies where a function's stack frame isstored in VRF 355A-N. While the set of stack frame tables 330A-N can beused in one implementation to track the mapping of stack frames toregister locations in VRF 355A-N, this does not preclude the use ofother mechanisms to track where stack frames for the various wavefrontfunctions are stored in VRF 355A-N. Accordingly, other techniques fortracking how stack frames are mapped to register locations are possibleand are contemplated. It is noted that the terms “stack frame”,“register frame”, and “allocated register frame” can be usedinterchangeably herein.

In one implementation, in order to determine which stack frame(s) todeallocate and spill, control unit 310 selects values based on arelative age of the stack frames in the register file. For example, inone implementation the control unit 310 determines which values in thestack frame table 330 correspond to the youngest in-flight wavefront,with the youngest in-flight wavefront identified by reservation station320. For example, in one implementation, assuming that stack frame table330A corresponds to the youngest in-flight wavefront, control unit 310selects the lowest (i.e., oldest) stack frame (i.e., the stack framethat is furthest from the top of the table 330A) that does not have aspill indicator field 347 set. In this example, entry 338 with trackingID 340 is the furthest from the top of table 330A. Accordingly, controlunit 310 would deallocate the registers, from range 00-0F, specified byentry 338 after verifying that its spill indicator field 347 is not set.It is noted that each entry 335-338 can also include any number ofadditional fields which are not shown in stack frame table 330A to avoidcluttering the figure.

When the registers from range 00-0F are deallocated, the spill indicatorfield 347 for entry 338 is set and the values stored by these registersare written back to memory subsystem 365. In one implementation, apre-reserved memory in a known location is used for storing the registerstack frame in memory. If more registers are needed than are availablefrom range 00-0F, then control unit 310 would move up the stack frametable 330A to entry 337 for the function with tracking ID 341,continuing to entry 336 for the function with tracking ID 342, and thenon to entry 335 for the function with tracking ID 343. As shown from theexpanded area above tracking ID 343, tracking ID 343 is created from theconcatenation of workgroup ID 345 and frame ID 347. The tracking ID's ofthe other entries can also be generated from the concatenation of theworkgroup ID and the frame ID of the corresponding function. In oneimplementation, the frame ID is determined by the value of a framecounter (not shown) when a function is called. An example of a framecounter 430 for generating frame IDs is described in further detail inthe discussion associated with FIG. 4 .

If a group of registers are deallocated (i.e., spilled) for a wavefrontfunction, then control unit 310 increments spill counter 312. At the endof every epoch, control unit 310 compares spill counter 312 to registerspill threshold 313. The duration of an epoch can vary fromimplementation to implementation. If the spill counter 312 is greaterthan the register spill threshold 313 at the end of an epoch, thencontrol unit 310 causes the launching of new workgroups to be throttled.In other words, the rate at which new workgroups are launched in a newepoch is reduced if the spill counter 312 is greater than the registerspill threshold 313 for the previous epoch. The spill counter 312 isreset at the end of each epoch.

After registers are dynamically allocated for a new wavefront functionby control unit 310, the stack frame for the new wavefront function isstored in the assigned registers of VRF 355A-N. Also, a new entry isadded to the top of the corresponding stack frame table 330A-N toidentify the range of registers that are allocated to the wavefrontfunction's stack frame. In one implementation, each stack frame table330A-N is a first-in, first-out (FIFO) buffer. In one implementation,the new entry includes a workgroup ID field 340 and frame ID field 345which identify the specific wavefront, as shown in the expanded box fortracking ID 343 of entry 335 of stack frame table 330A. In otherimplementations, other ways of identifying a specific wavefront functioncan be used in each entry of stack frame tables 330A-N.

When a new wavefront is launched on SIMD units 350A-N by dispatch unit305, an entry for the new wavefront is added to reservation station 320.When a given wavefront finishes execution, the entry in reservationstation 320 for the given wavefront is retired, and the stack frametable 330A-N corresponding to the given wavefront is freed up for use byother wavefronts. Also, when a wavefront is retired, its registers willbe returned to free register list 317 of register assignment unit 315.These registers will then be available for any new wavefronts that aredispatched to SIMD units 350A-N by dispatch unit 305.

It is noted that the arrangement of components such as dispatch unit305, control unit 310, and register assignment unit 315 shown in FIG. 3is merely representative of one implementation. In anotherimplementation, dispatch unit 305, control unit 310, and registerassignment unit 315 are combined into a single unit. In otherimplementations, the functionality of dispatch unit 305, control unit310, and register assignment unit 315 can be partitioned into otherunits in varying manners. Also, it is noted that the reference numeralsA-N for different components do not necessarily mean that there are thesame number of units of these different components. For example, thenumber “N” of SIMD units 350A-N can be different from the number “N” ofstack frame tables 330A-N.

Turning now to FIG. 4 , a block diagram of one implementation of acontrol unit 400 is shown. In one implementation, the components andfunctionality of control unit 400 are included in compute unit 300 (ofFIG. 3 ). In one implementation, control unit 400 detects when stackframes associated with the same wavefronts are continuously spilled andrestored. When the spilling and restoring of stack frames reaches athreshold level, control unit 400 attempts to limit this resourcecontention by reducing the number of workgroups that are dispatched perepoch. Various mechanisms for tracking the spilling and restoring ofstack frames are depicted in FIG. 4 . However, it should be understoodthese are intended to be non-limiting examples of resource contentiontracking mechanisms.

In one implementation, each workgroup is assigned a unique identifier(ID) and each frame is identified by the value of frame counter 430 whenthe frame is pushed onto a corresponding stack 410. In oneimplementation, frame counter 430 that is incremented every time a frameis pushed onto a stack 410 and decremented every time a frame is poppedfrom the stack 410. In one implementation, the contents of stack(s) 410are mirrored into register file 420 on a frame by frame basis atwavefront function call boundaries. In one implementation, the top ofeach stack 410 is maintained in register file 420 by spilling the lowestentries of stack 410 to memory (not shown) to make room for new framespushed onto stack 410.

In one implementation, the unique workgroup ID and the value of framecounter 430 when a frame is pushed onto stack 410 are concatenatedtogether and hashed into one of two counting bloom filters 435 and 440.As used herein, a “bloom filter” is defined as a probabilistic datastructure used to test whether an element is a member of a set. In oneimplementation, bloom filter 435 tracks recently spilled frames andbloom filter 440 tracks recently allocated frames. When a frame isspilled or allocated, the opposite bloom filter is checked. For example,if a frame is spilled, bloom filter 440 is checked. Or, if a frame isallocated, bloom filter 435 is checked. If there is a hit when eitherbloom filter 435 or 440 is checked, then frame thrashing counter 445 isincremented. At the end of each epoch, the frame thrashing counter 445is compared to threshold 450. If the threshold 450 is reached, thencontrol unit 400 decrements the number of workgroups permitted to beassigned per epoch. The frame thrashing counter 445 and bloom filters435 and 440 are reset at the end of each epoch.

In various implementations, control unit 400 adjusts the spillingpolicies of workgroups based on tracking the thrashing of registersamong workgroups. In one implementation, each compute unit (e.g.,compute unit 300 of FIG. 3 ) starts out in least recently used (LRU)spilling mode, with LRU spilling mode selecting the registers of theleast recently executed workgroup to spill to memory when more registersare needed. In one implementation, if bloom filters 435 and 440 detectthrashing above threshold 455, then the compute unit is switched into“spill from the youngest workgroup” mode. In “spill from the youngestworkgroup” mode, control unit 400 selects registers to be spilled fromthe youngest in-flight workgroup when registers need to be allocated toa newly dispatched workgroup.

In one implementation, if thrashing is not detected for a given numberof epochs, the compute unit switches back into “LRU spilling” mode andgives the younger workgroups a new chance to run by spilling frames ofolder workgroups that have not been accessed in the longest timerelative to the other in-flight workgroups. In one implementation, theabove mechanism is refined by a local workgroup limit 460 that isdecreased on thrashing and increased when no thrashing occurs. In thisimplementation, if the local workgroup limit 460 is equal to “N”, thenthe “N” oldest workgroups are allowed to allocate stack frames on acorresponding compute unit even when this requires spilling. In thiscase, younger workgroups' frames are preferably spilled, and youngerworkgroups are forbidden from causing another workgroup to spill. Asused herein, the term “local workgroup limit” is defined as a number ofthe oldest workgroups that are allowed to allocate stack frames on agiven compute unit. In another implementation, the younger workgroupsare forbidden from allocating stack frames altogether. In a furtherimplementation, rather than using local workgroup limit 460, themechanism references a workgroup limit which is determined based onframe thrashing counter 445 and bloom filters 435 and 440.

It is noted that the arrangement of components in FIG. 4 are indicativeof one particular implementation. In other implementations, otherarrangements of components can be used. Also, it should be understoodthat control unit 400 can also be coupled to various other componentswhich are not shown to avoid obscuring the figure.

Referring now to FIG. 5 , one implementation of a method 500 for dynamicregister allocation is shown. For purposes of discussion, the steps inthis implementation and those of FIG. 6-14 are shown in sequentialorder. However, it is noted that in various implementations of thedescribed methods, one or more of the elements described are performedconcurrently, in a different order than shown, or are omitted entirely.Other additional elements are also performed as desired. Any of thevarious systems or apparatuses described herein are configured toimplement method 500.

A control unit (e.g., control unit 240 of FIG. 2 ) monitors wavefrontsdispatched by a dispatch unit (e.g., dispatch unit 250) for execution onthe compute units (e.g., compute units 255A-N) of a processing unit(e.g., GPU 205) (block 505). When needed by a wavefront, the controlunit determines how many registers are needed (block 510). In oneimplementation, when a function call is detected, the control unitdetermines how many registers the callee function needs. In oneimplementation, the callee function includes an indication, generated bya compiler, indicating how many registers it needs. In otherimplementations, other ways of determining how many registers the calleefunction needs are possible and are contemplated. It is noted that inother implementations, the register allocation and deallocationdecisions can be decoupled from function call and return boundaries.

Next, the control unit determines if there are enough availableregisters (e.g., to allocate to the callee function) (conditional block515). If there are enough available registers to allocate (conditionalblock 515, “yes” leg), then the control unit stores the stack frame inavailable registers and removes these registers from the free list(block 520). In one implementation, the available registers are acontiguous range in the register file. The control unit also adds anentry to a data structure such as a stack table or otherwise (e.g., forthe callee function) to identify the mapping of the stack frame to theregister file (block 525). After block 525, method 500 returns to block510.

If there are not enough available registers to allocate to the calleefunction (conditional block 515, “no” leg), then the control unitdeallocates registers from the lowest stack frame(s) associated with theyoungest workgroup (block 530). If the lowest frame(s) have enoughregisters for the callee function, then the control unit will onlydeallocate registers for the lowest frame(s). If the new wavefront needsmore registers than are available from the youngest workgroup, then thecontrol unit deallocates registers for the next youngest workgroup. Thecontrol unit can keep moving through the workgroups until enoughregisters have been deallocated. The control unit stores a spillindicator for each frame that has its registers deallocated (block 535).Next, the control unit stores the stack frame for the callee function inregister locations freed up by spilling the register values to memory(block 540). The control unit also adds an entry to a stack table forthe callee function to identify the mapping of the stack frame to theregister file (block 545). After block 545, method 500 returns to block510. It is noted that while the above contemplates allocating anddeallocating registers based on function calls and returns, this neednot be the case. In some embodiments, a device program may havedifferent stages with each using a different number of registers.However, through the use of inlining or other design techniques, theentire program may consist of only a single function (e.g., a mainfunction). The methods and mechanisms described herein are applicable tothese and other embodiments.

Turning now to FIG. 6 , one implementation of a method 600 fordetermining when to throttle the launching of new workgroups is shown. Acontrol unit starts an epoch counter at a beginning of an epoch (block605). During the epoch, the control unit monitors when wavefronts spillregisters to cache/memory (block 610). Each time a wavefront spills itsregisters (conditional block 615, “yes” leg), the control unitincrements a spill counter (e.g., spill counter 312 of FIG. 3 ) (block620) and stores a spill indicator for each frame that has its registersspilled (block 625).

If the control unit does not detect a wavefront having spilled itsregisters (conditional block 615, “no” leg), then the control unitdetermines if the epoch has ended (conditional block 630). If the end ofthe epoch has been reached (conditional block 630, “yes” leg), then thecontrol unit compares the spill counter to a register spill threshold(block 635). If the spill counter is greater than the register spillthreshold (conditional block 640, “yes” leg), then the control unitreduces the number of new wavefronts that are launched in the next epoch(block 645). Otherwise, if the spill counter is less than or equal tothe register spill threshold (conditional block 640, “no” leg), then thecontrol unit increases the number of new wavefronts that are allowed tolaunch in the next epoch (block 650). It is noted that if the number ofnew waveforms allowed to launch has already reached a maximum value or awavefront launch threshold, then the number of new waveforms that areallowed to launch in the next epoch can remain the same in block 650.After blocks 645 and 650, the control unit resets the epoch and spillcounters (block 655), and then method 600 returns to block 605.

Referring now to FIG. 7 , one implementation of a method 700 foradjusting the number of workgroups permitted to be assigned is shown. Acontrol unit assigns each workgroup a unique identifier (ID) andidentifies each frame using a frame counter that is incremented everytime a frame is pushed onto a stack and decremented every time a frameis popped from the stack (block 705). The control unit maintains twobloom filters that are indexed by concatenating the workgroup ID withthe frame ID for a corresponding frame (block 710). If a function iscalled and a frame is pushed onto the stack (conditional block 715,“yes” leg), then the workgroup ID concatenated with the frame ID of thenew frame is hashed into a first bloom filter (block 720). In otherimplementations, other ways of generating an ID can be used for uniquelyidentifying the new frame, and this ID can be hashed into the firstbloom filter in block 730. Also, if, as a result of the frame beingpushed onto the stack (conditional block 715, “yes” leg), a previousframe is spilled from the register file (conditional block 725, “yes”leg), then the workgroup ID concatenated with the frame ID of theprevious frame is hashed into a second bloom filter (block 740). Inother implementations, other ways of generating an ID can be used foruniquely identifying the previous frame, and this ID can be hashed intothe second bloom filter in block 740.

If the lookup of the first bloom filter results in a hit (conditionalblock 730, “yes” leg), then a frame thrashing counter is incremented(block 735). If the lookup of the second bloom filter results in a hit(conditional block 745, “yes” leg), then the frame thrashing counter isincremented (block 750). Next, if the end of an epoch has been reached(conditional block 755, “yes” leg), then the frame thrashing counter iscompared to a threshold (conditional block 760). The value of thethreshold can vary according to the implementation. If the framethrashing counter is greater than the threshold (conditional block 760,“yes” leg), then the control unit reduces the number of workgroups thatare permitted to be launched in the next epoch (block 765). Next, thebloom filter counters and the epoch counter are reset (block 770), andthen method 700 returns to block 705.

It is noted that variations to the above steps of method 700 arepossible and are contemplated. For example, in one implementation, theaddress of memory to which registers are spilled and restored is used asa key when accessing the probabilistic data structure (e.g., bloomfilter). In one implementation, the control unit writes to theprobabilistic data structure during spilling and reads from theprobabilistic data structure during restoring. In one implementation,the number of wavefronts that are allowed to execute concurrently isdecreased in the control unit after a period in which thrashing isdetected. Also, the number of wavefronts that are allowed to executeconcurrently is increased after a period in which no thrashing isdetected. In one implementation, the detection is based on somethreshold, and the threshold for increasing the number of wavefrontsallowed to execute concurrently can be different from the threshold fordecreasing the number of wavefronts allowed to execute concurrently. Inone implementation, wavefront execution limits are determinedindividually per compute unit. In one implementation, a singleper-compute-unit wavefront execution limit is determined based onfeedback from all compute units, and applied equally to all of them.

Turning now to FIG. 8 , one implementation of a method 800 for switchingbetween spilling modes is shown. A processing unit (e.g., GPU 205 ofFIG. 2 ) executes a plurality of workgroups concurrently (block 805). Acontrol unit tracks how recently each workgroup was executed (block810). Each compute unit (e.g., compute unit 300 of FIG. 3 ) starts outin least recently used (LRU) spilling mode based on how recently eachworkgroup was executed (block 815). In LRU spilling mode, a compute unitspills registers from the least recently executed workgroup regardlessof the age of the workgroup. LRU spilling mode allows younger workgroupsto use registers previously allocated to older workgroups that arestalled. In other words, stalled older workgroups have their assignedphysical register locations deallocated so that these register locationscan be used by younger workgroups.

Next, if register thrashing above a threshold is detected (conditionalblock 820, “yes” leg), then the compute units switch into spilling fromthe youngest workgroup mode (block 825). The threshold can be specifiedin terms of a number of register/frame spills per epoch, with thethreshold amount varying from implementation to implementation. In thespilling from the youngest workgroup mode, the compute units spill fromthe youngest workgroup that is in-flight on the processing unit. In oneimplementation, the processing unit uses bloom filters to detectregister thrashing. In other implementations, other techniques fordetecting register thrashing can be employed. If register thrashingfalls below the threshold for a given number of epochs (conditionalblock 830, “yes” leg), then the compute units switch back into LRUspilling mode (block 835) and then method 800 returns to conditionalblock 820. If register thrashing does not fall below the threshold for agiven number of epochs (conditional block 830, “no” leg), then thecompute units stay in spilling from the youngest workgroup mode (block840) and then method 800 returns to conditional block 830.

Referring now to FIG. 9 , one implementation of a method 900 fordetermining workgroups that are allowed to cause spilling is shown. Aprocessing unit (e.g., GPU 205 of FIG. 2 ) executes a plurality ofworkgroups concurrently (block 905). A control unit (e.g., control unit310 of FIG. 3 ) of the processing unit monitors register thrashing bythe plurality of workgroups (block 910). For example, in oneimplementation, the control unit maintains a spill counter to monitorthe number of register spills per epoch. In other implementations, thecontrol unit uses other techniques for monitoring register thrashing.Also, the control unit monitors relative ages of the in-flightworkgroups (block 915). Still further, the control unit maintains alocal workgroup limit counter which determines a number of the oldestworkgroups that are allowed to allocate stack frames even when thisrequires spilling (block 920). For example, when the local workgrouplimit counter is equal to N, where N is a positive integer, the N oldestworkgroups are allowed to allocate stack frames even when this requiresspilling. Younger workgroups' frame are preferably spilled in thesecases. In one implementation, younger workgroups are forbidden fromcausing another workgroup to spill. In another implementation, youngerworkgroups are forbidden from allocating stack frames altogether.

Next, if register thrashing above a certain threshold is detected(conditional block 925, “yes” leg), then the local workgroup limitcounter is decremented (block 930). If the local workgroup limit counteris already at a minimum level, then the local workgroup limit countercan remain the same at block 930. If register thrashing below thethreshold is detected (conditional block 925, “no” leg), then the localworkgroup limit counter is incremented (block 935). If the localworkgroup limit counter is already at a maximum level, then the localworkgroup limit counter can remain the same at block 935. After blocks930 and 935, method 900 returns to block 910.

Turning now to FIG. 10 , one implementation of a method 1000 forcooperative wavefront scheduling is shown. A plurality of wavefronts arelaunched for concurrent execution on a processing unit (e.g., GPU 205 ofFIG. 2 ) (block 1005). A dispatch unit (e.g., dispatch unit 305 of FIG.3 ) maintains an ordered list of the plurality of wavefronts (block1010). The dispatch unit detects a request to launch a new wavefrontwhen not enough resources (e.g., registers) are currently available onthe processing unit to support the new wavefront (block 1015). Inresponse to there not being enough resources for the new wavefront, thedispatch unit waits for one of the in-flight wavefronts to reach asynchronization point (block 1020). Alternatively, the dispatch unitwaits for one of the in-flight wavefronts to stall in block 1020. In oneimplementation, the synchronization point is a wavefront in a spin loopwaiting for an atomic variable to be set. In another implementation, thesynchronization point involves an in-flight wavefront waiting for amessage. In a further implementation, the synchronization point involvesan in-flight wavefront waiting for a long-latency memory request. In astill further implementation, the synchronization point is a barrierinstruction. In other implementations, other types of synchronizationpoints can be employed.

Once a given in-flight wavefront reaches a synchronization point(conditional block 1025, “yes” leg), the dispatch unit causes the givenin-flight wavefront to be descheduled (block 1030). Also, the resourcesof the given wavefront are released back into the pool of free resources(block 1035). Next, the new wavefront is dispatched for execution by thedispatch unit using the resources released by the given wavefront (block1040). After block 1040, method 1000 ends.

Referring now to FIG. 11 , one implementation of a method 1100 forwavefront descheduling and rescheduling is shown. A plurality ofwavefronts are launched for concurrent execution on a processing unit(e.g., GPU) (block 1105). The plurality of wavefronts can be associatedwith any number of workgroups, from 1 to N, where N is a positiveinteger. A dispatch unit (e.g., dispatch unit 305 of FIG. 3 ) maintainsan ordered list of the plurality of in-flight wavefronts (block 1110).In one implementation, the ordered list orders in-flight wavefronts byage. A control unit (e.g., control unit 310 of FIG. 3 , control unit 400of FIG. 4 ) monitors the scheduling and descheduling of the plurality ofwavefronts executing on the compute units of the processing unit (block1115). If an oldest in-flight wavefront previously descheduled is nowready to resume execution (conditional block 1120, “yes” leg), then thecontrol unit selects a younger in-flight wavefront from the ordered list(block 1125). The younger in-flight wavefront that is selected can bethe youngest in-flight wavefront, the in-flight wavefront using the mostresources, or the in-flight wavefront that meets other criteria. In oneimplementation, the vector register file is a primary resource beingoptimized by method 1100.

Next, the control unit causes the selected younger in-flight wavefrontto be descheduled (block 1130). The control unit causes the resourcesassigned to the younger descheduled in-flight wavefront to be released(block 1135). The control unit causes the oldest in-flight wavefront tobe resumed using the resources released by the younger in-flightwavefront (block 1140). For example, in one implementation, the oldestin-flight wavefront uses physical registers previously allocated to theyounger in-flight wavefront to restore values from cache/memory. Afterblock 1140, method 1100 ends. By implementing method 1100, the oldestin-flight wavefront can be descheduled when waiting for asynchronization event without ultimately creating a deadlock situation.A deadlock could occur if the oldest in-flight wavefront is not broughtback onto the machine to generate data needed by a younger in-flightwavefront. Method 1100 allows the oldest in-flight wavefront to beresumed after previously being descheduled. By descheduling olderwavefronts that are stalled, younger wavefronts can be scheduled,allowing for better utilization of the machine.

Turning now to FIG. 12 , one implementation of a method 1200 fordynamically adjusting register allocation on function boundaries isshown. A processing unit (e.g., GPU 205 of FIG. 2 ) executes a firstwavefront (block 1205). A control unit (e.g., control unit 310 of FIG. 3, control unit 400 of FIG. 4 ) allocates a first number of registers fora first function of the first wavefront (block 1210). Next, the firstfunction calls a second function (block 1215). On the call boundarybetween the first function and the second function, the control unitdynamically adjusts the number of registers allocated to the firstwavefront to a second number of registers different from the firstnumber of registers (block 1220). It is assumed for the purposes of thisdiscussion that the second function needs or requests a different numberof registers needed by the first function. In one implementation, anindication of the second number of registers needed by the secondfunction is generated by a compiler as a compiler hint. In oneimplementation, the control unit detects the compiler hint responsive tothe second function being called. In another implementation, the controlunit dynamically adjusts the number of registers allocated to the firstwavefront at a different point in time unrelated to the call boundarybetween the first function and the second function.

If the second number of registers is greater than the first number ofregisters (conditional block 1225, “yes” leg), then the control unitspills a number of values from a third number of registers to memory(block 1230). It is assumed for the purposes of this discussion that thethird number is equal to the difference between the second number andthe first number. In one implementation, the third number of registersare selected based on being allocated for a lowest one or more stackframes of all outstanding stack frames. Otherwise, if the second numberof registers is less than or equal to the first number of registers(conditional block 1225, “no” leg), then the control unit returns athird number of registers to the free list to potentially be provided toanother wavefront (block 1235). After blocks 1230 and 1235, method 1200ends.

It is noted that method 1200 is an example of a method that can beimplemented on call boundaries. It is also noted that method 1200 can berepeated at each call boundary when the number of registers allocated tothe callee function is not equal to the number of registers allocated tothe calling function.

Referring now to FIG. 13 , one implementation of a method 1300 fordynamically allocating registers to ensure forward progress is shown. Aprocessing unit (e.g., GPU 205 of FIG. 2 ) executes first and secondwavefronts concurrently, with the first wavefront being older than thesecond wavefront (block 1305). A control unit (e.g., control unit 310 ofFIG. 3 ) allocates a first number of registers to the first wavefrontand a second number of registers to the second wavefront (block 1310).The control unit monitors the fluctuating register needs by the firstand second wavefronts at call boundaries (block 1315). During execution,the control unit detects a function call by the first wavefront thatresults in the first wavefront needing more registers (block 1320). Inresponse to detecting the function call by the first wavefront thatresults in the first wavefront needing more registers, the control unitspills a third number of registers from a function of the secondwavefront having a lowest stack frame of the stack frames of the secondwavefront (block 1325). In other implementation, other selectioncriteria can be used to select which registers are spilled to memory.For example, in another implementation, the wavefront with the shorteststack is selected for spilling registers to memory. Also, the controlunit increments a spill counter (block 1330). It is noted that the spillcounter can be compared to a spill threshold periodically so as toadjust the number of wavefronts that are permitted to execute on themachine. Next, the control unit allocates the third number of registersto the callee function of the first wavefront to ensure forward progress(block 1335). After block 1335, method 1300 ends.

Turning now to FIG. 14 , one implementation of a method 1300 fordynamically adjusting wavefronts executing per epoch based on an amountof register threshing is shown. A control unit (e.g., control unit 310of FIG. 3 ) allows a first number of wavefronts to execute on aplurality of compute units (e.g., compute units 255A-N of FIG. 2 )during a first interval (block 1405). The duration of the interval canvary according to the implementation. The control unit monitorsthrashing of a physical register file during the first interval (block1410). In one implementation, the control unit maintains a spill counterwhich is incremented each time a frame of registers is spilled tomemory. In other implementations, the control unit uses other techniquesfor monitoring register thrashing. If the thrashing of the physicalregister file exceeds a first threshold (conditional block 1415, “yes”leg), then the control unit allows a second number of wavefronts toexecute on the plurality of compute units during a second interval, withthe second number being less than the first number (block 1420). It isassumed for the purposes of this discussion that the second interval issubsequent to the first interval.

If the thrashing of the physical register file is less than a secondthreshold (conditional block 1425, “yes” leg), then the control unitallows a third number of wavefronts to execute on the plurality ofcompute units during the second interval, with the third number beinggreater than the first number (block 1430). It is assumed for thepurposes of this discussion that the second threshold is less than thefirst threshold. Otherwise, if the thrashing of the physical registerfile is in between the first and second thresholds (conditional block1425, “no” leg), then the control unit allows the first number ofwavefronts to execute on the plurality of compute units during thesecond interval (block 1435). After blocks 1420, 1430, and 1435, method1400 ends. It is noted that method 1400 can be repeated in subsequentintervals to adjust the number of wavefronts that are allowed to executeconcurrently on the compute units.

In various implementations, program instructions of a softwareapplication are used to implement the methods and/or mechanismsdescribed herein. For example, program instructions executable by ageneral or special purpose processor are contemplated. In variousimplementations, such program instructions are represented by a highlevel programming language. In other implementations, the programinstructions are compiled from a high level programming language to abinary, intermediate, or other form. Alternatively, program instructionsare written that describe the behavior or design of hardware. Suchprogram instructions are represented by a high-level programminglanguage, such as C. Alternatively, a hardware design language (HDL)such as Verilog is used. In various implementations, the programinstructions are stored on any of a variety of non-transitory computerreadable storage mediums. The storage medium is accessible by acomputing system during use to provide the program instructions to thecomputing system for program execution. Generally speaking, such acomputing system includes at least one or more memories and one or moreprocessors configured to execute program instructions.

It should be emphasized that the above-described implementations areonly non-limiting examples of implementations. Numerous variations andmodifications will become apparent to those skilled in the art once theabove disclosure is fully appreciated. It is intended that the followingclaims be interpreted to embrace all such variations and modifications.

What is claimed is:
 1. An apparatus comprising: a register filecomprising a plurality of registers; a plurality of compute unitscomprising circuitry; and a control unit comprising circuitry configuredto: allow a first number of wavefronts to execute concurrently on theplurality of compute units; and allow no more than a second number ofwavefronts to execute concurrently on the plurality of compute units,wherein the second number is less than the first number, in response todetection that thrashing of the register file is above a threshold. 2.The apparatus as recited in claim 1, wherein the control unit isconfigured to detect said thrashing based at least in part on a numberof registers in use by executing wavefronts that spill to memory.
 3. Theapparatus as recited in claim 1, wherein the control unit is configuredto compare the number of registers that spill to the memory on aperiodic basis.
 4. The apparatus as recited in claim 1, wherein thecontrol unit is configured to determine said thrashing is above thethreshold based at least in part on an access to a probabilistic datastructure.
 5. The apparatus as recited in claim 4, wherein the controlunit is configured to access the probabilistic data structure usingidentifiers of a given workgroup and a given corresponding frame.
 6. Theapparatus as recited in claim 5, wherein the control unit is configuredto access the probabilistic data structure using a concatenation of theidentifier of the given workgroup and the identifier of the givencorresponding frame.
 7. The apparatus as recited in claim 1, furthercomprising a first probabilistic data structure and a secondprobabilistic data structure, wherein the control unit is configured toaccess the first probabilistic data structure when register values arespilled to the memory and access the second probabilistic data structurewhen register values are restored from the memory to the register file.8. A method comprising: allowing, by circuitry, a first number ofwavefronts to execute concurrently on a plurality of compute units, inresponse to detecting that thrashing of a register file is below athreshold; and allowing, by the circuitry, no more than a second numberof wavefronts to execute concurrently on the plurality of compute units,wherein the second number is less than the first number, in response todetecting that thrashing of the register file is above a threshold. 9.The method as recited in claim 8, further comprising detecting saidthrashing based at least in part on a number of registers in use byexecuting wavefronts that spill to memory.
 10. The method as recited inclaim 8, further comprising comparing the number of registers that spillto the memory on a periodic basis.
 11. The method as recited in claim 8,further comprising determining said thrashing is above the thresholdbased at least in part on an access to a probabilistic data structure.12. The method as recited in claim 11, further comprising accessing theprobabilistic data structure using identifiers of a given workgroup anda given corresponding frame.
 13. The method as recited in claim 12,further comprising accessing the probabilistic data structure using aconcatenation of the identifier of the given workgroup and theidentifier of the given corresponding frame.
 14. The method as recitedin claim 8, further comprising access a first probabilistic datastructure when register values are spilled to the memory, and accessinga second probabilistic data structure, different from the firstprobabilistic data structure, when register values are restored from thememory to the register file.
 15. An apparatus comprising: a thresholdregister configured to store a threshold value; wherein the apparatuscomprises circuitry configured to: monitor a number of wavefrontsconcurrently executing on a plurality of compute units; increase amaximum number of wavefronts permitted to concurrently execute, inresponse to detecting thrashing of a register file is below a valuestored in the threshold register; and decrease the maximum number ofwavefronts permitted to concurrently execute, in response to detectingthrashing of the register file is above the value stored in thethreshold register.
 16. The apparatus as recited in claim 15, furthercomprising a workgroup limit register configured to store a value thatindicates a number of workgroups that are permitted to spill registervalues to memory.
 17. The apparatus as recited in claim 16, wherein thevalue stored by the workgroup limit register indicates how many oldestworkgroups are permitted to allocate frames even if spilling isrequired.
 18. The apparatus as recited in claim 15, wherein theapparatus is configured to decrement a value stored in the workgrouplimit register in response to detecting thrashing of the register fileis above the value stored in the threshold register.
 19. The apparatusas recited in claim 15, wherein the apparatus is configured to spillregister values corresponding to older wavefronts responsive tothrashing being below the threshold.
 20. The apparatus as recited inclaim 19, wherein the apparatus is configured to switch from spillingregister values of least recently executed wavefronts to spillingregister values of wavefronts that are younger than other wavefrontsbeing executed, response to thrashing being above the threshold.